﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<SetListManager.Models.SetListSongsModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Details
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h1>Set List Details<br />
    <%: Html.DisplayFor(m=>Model.SetList.Name) %> - <%: Html.DisplayFor(m=>Model.SetList.GigDate) %> (ID <%: Html.DisplayFor(m=>Model.SetList.SetListID) %>)
</h1>
    <p>
        <%: Html.ActionLink("Edit", "Edit", new { /* id=Model.PrimaryKey */ }) %> |
        <%: Html.ActionLink("Back to List", "Index") %>
    </p>

    <table>
        <tr>
            <th>Song Name</th>
            <th>Song Duration</th>
            <th>
                SetListID
            </th>
            <th>
                SetNumber
            </th>
            <th>
                SongOrder
            </th>
        </tr>

    <% 
        // Create headings for each set number.  NOTE that this code requires that the 
        // songs in our model are sorted by set number, with the lowest set number first.
        
        int current_setnumber = 0;
        
        foreach (var item in Model.SetListItems) { 
            if (item.SetNumber > current_setnumber)
            {
                // We have a new set number, create heading for it
                %>
                <tr><td style="font-weight:bold; background-color:Yellow;" colspan="5">Set <% = item.SetNumber %></td></tr>
                <%
                current_setnumber = item.SetNumber;    
            }
            
            // Determine if this is a note or a song
            if (item.Song == null)
            {
                // It's a note, display note
                %>
                <tr><td style="font-weight: bold;margin-left: 5px;" colspan="2"><% = item.Note %></td>
                <td><%:item.SetListID %></td>
                <td><%:item.SetNumber %></td>
                <td><%:item.SongOrder %></td>
                </tr>
                <%

            }
            else
            {
                // It's a song, display song
            %>
            <tr>
                <td><%: item.Song.Title %></td>
                <td><%: item.Song.Duration.FormatMinSec %></td>
                <td>
                    <%: item.SetListID %>
                </td>
                <td>
                    <%: item.SetNumber %>
                </td>
                <td>
                    <%: item.SongOrder %>
                </td>
            </tr>
            <% 
            } // end else %>            
   
    <% } %>

    </table>

    <p>
        <%: Html.ActionLink("Create New", "Create") %>
    </p>

</asp:Content>

